import request from '@/utils/request'

export let GetSysRolePage = (pageNum, pageSize, keyword) => {
  return request({
    url: `/admin/system/role/page/${pageNum}/${pageSize}`,
    method: 'get',
    params: { keyword },
  })
}

export let DeleteRoleById = id => {
  return request({
    url: `/admin/system/role/deleteById/${id}`,
    method: 'delete',
  })
}

export let GetRoleById = id => {
  return request({
    url: `/admin/system/role/GetRoleById/${id}`,
    method: 'get',
  })
}

export let UpdateRoleById = role => {
  return request({
    url: `/admin/system/role/UpdateRoleById`,
    method: 'put',
    data: role,
  })
}
export let saveRole = role => {
  return request({
    url: `/admin/system/role/save`,
    method: 'post',
    data: role,
  })
}
export let getRoles = id => {
  return request({
    url: `/admin/system/role/getRole/${id}`,
    method: 'get',
  })
}

export const AssignRoles2User = (userId, roleIds) => {
  return request({
    url: `/admin/system/userRole/assignRoles2User/${userId}`,
    method: 'put',
    data: roleIds,
  })
}

export const GetMenuById = roleId => {
  return request({
    url: `/admin/system/roleMenu/findMenusByRoleId/${roleId}`,
    method: 'get',
  })
}

export const AssignMenus2Role = (roleId, menuIds) => {
  return request({
    url: `/admin/system/roleMenu/assignMenus2Role/${roleId}`,
    method: 'put',
    data: menuIds,
  })
}
